/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.hwr.nbaplan.shared.model;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author flo
 */
@Entity
@Table(name = "t_studiengang", catalog = "nbaplan", schema = "", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"name"})})
@NamedQueries({
    @NamedQuery(name = "Studiengang.findAll", query = "SELECT s FROM Studiengang s"),
    @NamedQuery(name = "Studiengang.findById", query = "SELECT s FROM Studiengang s WHERE s.id = :id"),
    @NamedQuery(name = "Studiengang.findByName", query = "SELECT s FROM Studiengang s WHERE s.name = :name")})
public class Studiengang implements Serializable {
   
    @Basic(optional = false)
    @Column(name = "kurzform", nullable = false, length = 10)
    private String kurzform;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @Column(name = "name", nullable = false, length = 255)
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fStudiengang")
    private Collection<Kurs> kursCollection;
    @Basic(optional = false)
    @Column(name = "lastCrowl", nullable = false)
    @Temporal(value = TemporalType.DATE)
    private Calendar lastCrowl;

    /**
     *
     */
    public Studiengang() {
    }

    /**
     *
     * @param id
     */
    public Studiengang(Integer id) {
        this.id = id;
    }

    /**
     *
     * @param id
     * @param name
     */
    public Studiengang(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    /**
     *
     * @return
     */
    public Integer getId() {
        return id;
    }

    /**
     *
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     *
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

 

    /**
     *
     * @return
     */
    public Collection<Kurs> getKursCollection() {
        return kursCollection;
    }

    /**
     *
     * @param kursCollection
     */
    public void setKursCollection(Collection<Kurs> kursCollection) {
        this.kursCollection = kursCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Studiengang)) {
            return false;
        }
        Studiengang other = (Studiengang) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "de.hwr.nbaplan.shared.model.Studiengang[id=" + id + "]";
    }

    /**
     *
     * @param kurs
     * @return
     */
    public String getICSUrl(Kurs kurs) {
        //http://ipool.ba-berlin.de/stundenplaene/wi/semester6/kursa.ics
        return "http://ipool.ba-berlin.de/stundenplaene/"+this.getKurzform()+"/semester"+kurs.getSemester()+"/kurs"+kurs.getMyKursChar()+".ics";
    }
    /**
     *
     * @param sem
     * @param kurs
     * @return
     */
    public String getICSUrl(int sem, String kurs) {
        //http://ipool.ba-berlin.de/stundenplaene/wi/semester6/kursa.ics
        return "http://ipool.ba-berlin.de/stundenplaene/"+this.getKurzform()+"/semester"+sem+"/kurs"+kurs+".ics";
    }

    /**
     *
     * @return
     */
    public String getKurzform() {
        return kurzform;
    }

    /**
     *
     * @param kurzform
     */
    public void setKurzform(String kurzform) {
        this.kurzform = kurzform;
    }

    /**
     * @return the lastCrowl
     */
    public Calendar getLastCrowl() {
        return lastCrowl;
    }

    /**
     * @param lastCrowl the lastCrowl to set
     */
    public void setLastCrowl(Calendar lastCrowl) {
        this.lastCrowl = lastCrowl;
    }

   

   

}
